{% if page.comments != false %}
  {% case site.comments_provider %}
    {% when 'disqus' %}
      {% if site.disqus_username %}
        {% assign load_disqus = true %}
        <!-- Disqus Protection, see https://github.com/mzlogin/mzlogin.github.io/issues/2 -->
        {% if site.disqus_username == 'mzlogin' %}
          {% assign load_disqus = false %}
          {% if site.url contains 'mazhuang.org' %}
            {% assign load_disqus = true %}
          {% endif %}
        {% endif %}
        {% if load_disqus %}
          <div id="disqus_thread"></div>
          <script>
            var disqus_config = function () {
              this.page.url = '{{ site.url }}{{ page.url }}';
              this.page.identifier = '{{ page.url }}';
              this.page.title = '{{ page.title }}';
            };
            (function() { // DON'T EDIT BELOW THIS LINE
              var d = document, s = d.createElement('script');

              s.type = 'text/javascript';
              s.async = true;
              var shortname = '{{ site.disqus_username }}';

              s.src = '//' + shortname + '.disqus.com/embed.js';

              s.setAttribute('data-timestamp', +new Date());
              (d.head || d.body).appendChild(s);
            })();
          </script>
          <noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript" rel="nofollow">comments powered by Disqus.</a></noscript>
        {% endif %}
      {% endif %}
    {% when 'netease_gentie' %}
      {% if site.lazy_load_disqus and site.disqus_username %}
        <a href="#" class="show_disqus_comment" onclick="return false;">Show Disqus Comments</a>		
        <div id="disqus_thread"></div>		
        <script>		
        var disqus_config = function () {		
            this.page.url = '{{ site.url }}{{ page.url }}';		
            this.page.identifier = '{{ page.url }}';		
            this.page.title = '{{ page.title }}';		
        };		
        var disqus_loaded = false;		
        $(function() {		
            $('.show_disqus_comment').on('click', function() { // DON'T EDIT BELOW THIS LINE		
                $(this).html('加载中...');		
                var that = this;		
                if (!disqus_loaded) {		
                    var d = document, s = d.createElement('script');		

                    s.type = 'text/javascript';		
                    s.async = true;		
                    var shortname = '{{ site.disqus_username }}';		

                    s.src = '//' + shortname + '.disqus.com/embed.js';		

                    s.setAttribute('data-timestamp', +new Date());		
                    (d.head || d.body).appendChild(s);		

                    disqus_loaded = true;		
                }		
                $(that).remove();		
            })		
        })		
        </script>		
        <noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript" rel="nofollow">comments powered by Disqus.</a></noscript>		
      {% endif %}
      {% if site.netease_gentie_key %}
      <div id="cloud-tie-wrapper" class="cloud-tie-wrapper"></div>
      <script src="https://img1.cache.netease.com/f2e/tie/yun/sdk/loader.js"></script>
      <script>
      var cloudTieConfig = {
          url: "", 
          sourceId: "{{ page.url }}",
          productKey: "{{ site.netease_gentie_key }}",
          target: "cloud-tie-wrapper"
      };
      var yunManualLoad = true;
      Tie.loader("aHR0cHM6Ly9hcGkuZ2VudGllLjE2My5jb20vcGMvbGl2ZXNjcmlwdC5odG1s", true);
      </script>
    {% endif %}
  {% endcase %}
{% endif %}
